<template>
	<view class="evaluate">
		<scroll-view class="scrollWrap" :enhanced="true" scroll-y :bounces="false" :show-scrollbar="false">
			<view class="bg" v-if="dataObj.interiorImage">
				<image :src="$fullImageUrl(dataObj.interiorImage)"></image>
			</view>
			<view class="wrap">
				<view>
					<view>{{ dataObj.appraisalName }}</view>
					<view>{{ dataObj.summary }}</view>
					<view>
						<view class="bot">
							<view></view>
							<text>{{ dataObj.appraisalNumber }}道题</text>
						</view>
						<view class="bot">
							<view></view>
							<text>答题时间{{ dataObj.answerTime }}分钟</text>
						</view>
						<view class="bot">
							<view></view>
							<text>{{ dataObj.appraisalPeopleFalse }}人测过</text>
						</view>
					</view>
				</view>
				<view></view>
				<view class="setion">
					<view>
						<image :src="$buildFullImageUrl('/static/evaluate/introduce.svg')"></image>
						<text>测试介绍</text>
					</view>
					<view>
						{{ dataObj.appraisalIntroduce ? dataObj.appraisalIntroduce : '暂无' }}
					</view>
				</view>
				<view class="setion">
					<view>
						<image :src="$buildFullImageUrl('/static/evaluate/guidance.svg')"></image>
						<text>测试指导</text>
					</view>
					<view>
						{{ dataObj.appraisalInstruction ? dataObj.appraisalInstruction : '暂无' }}
					</view>
					<view>测试结果仅供参考，具体诊断或治疗请前往医院</view>
				</view>
				<view class="setion">
					<view>
						<image :src="$buildFullImageUrl('/static/evaluate/agree.svg')"></image>
						<text>同意书</text>
					</view>
					<view>
						我们郑重承诺对您在测评过程中提供的所有个人信息（包括但不限于姓名、年龄、性别、联系方式、测评结果等）严格保密。所有数据将以匿名化或编码的方式进行处理和存储，仅允许经过授权的相关人员在规定范围内使用。在研究报告或学术成果展示中，也不会出现任何能够识别您个人身份的信息。
					</view>
					<view>如您以充分理解并同意进行此次测评，请点击开始测评开始此次测试</view>
				</view>
				<view class="pos"></view>
			</view>
		</scroll-view>
		<view class="bot-wrap">
			<view class="strat" v-if="haveSuccessList.length === 0" @click="startText">开始测试</view>
			<view class="read strat" v-if="haveSuccessList.length !== 0" @click="ReadText">查看报告</view>
			<view class="again strat" v-if="haveSuccessList.length !== 0" @click="startText">再测一次</view>
		</view>
	</view>
</template>

<script>
import { getAppraisal, getUserAppraisalList, getUserAppraisalResult } from '@/api/evaluate/index.js';
export default {
	data() {
		return {
			dataObj: {},
			id: '',
			haveSuccessList: []
		};
	},
	onLoad(options) {
		this.id = options.id;
	},
	onShow() {
		getAppraisal(this.id).then((res) => {
			this.dataObj = res.data;
			uni.setNavigationBarTitle({
				title: this.dataObj.appraisalName
			});
		});
		//查询用户测评列表已完成
		getUserAppraisalList({
			appraisalId: this.id,
			userId: uni.getStorageSync('user_id'),
			appraisalStatus: '1'
		}).then((res) => {
			this.haveSuccessList = res.rows;
		});
	},
	methods: {
		handelScroll(event) {
			// console.log(event.detail);
		},
		startText() {
			// console.log(this.dataObj);
			// return
			this.$tab.navigateTo(`/subset/pages/evaluate/evaluateQuestion?id=${this.id}`);
		},
		ReadText() {
			console.log(this.haveSuccessList);
			if (this.haveSuccessList.length !== 0) {
				// this.$tab.navigateTo(
				// 	`/subset/pages/evaluate/evaluateResult?id=${this.haveSuccessList[this.haveSuccessList.length - 1].id}&appraisalId=${
				// 		this.haveSuccessList[this.haveSuccessList.length - 1].appraisalId
				// 	}`
				// );

				this.$tab.navigateTo(
					`/subset/pages/evaluate/evaluateResultReport?id=${this.haveSuccessList[this.haveSuccessList.length - 1].id}&appraisalId=${
						this.haveSuccessList[this.haveSuccessList.length - 1].appraisalId
					}`
				);
			}
		}
	}
};
</script>

<style scoped lang="scss">
.evaluate {
	width: 100%;
	height: 100%;
	overflow: hidden;
	.scrollWrap {
		width: 100%;
		height: 100%;
	}
	.bg {
		width: 100%;
		height: 368rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
	.wrap {
		width: 100%;
		padding: 0 30rpx 0 32rpx;
		box-sizing: border-box;
		position: relative;
		> view:nth-child(1) {
			width: calc(100% - 62rpx);
			height: 242rpx;
			position: absolute;
			top: -32rpx;
			background: #ffffff;
			border-radius: 20rpx;
			padding: 24rpx 20rpx 28rpx 34rpx;
			box-sizing: border-box;
			> view {
				width: 100%;
			}
			> view:nth-child(1) {
				font-weight: bold;
				font-size: 32rpx;
				color: #333333;
				margin-bottom: 22rpx;
			}
			> view:nth-child(2) {
				font-weight: 400;
				font-size: 26rpx;
				color: #80808b;
			}
			> view:last-child {
				border-top: 2rpx solid #ebebeb;
				width: 100%;
				margin-top: 34rpx;
				padding-top: 22rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;
				.bot {
					display: flex;
					align-items: center;
					> view {
						width: 8rpx;
						height: 8rpx;
						background: #c1c1c1;
						border-radius: 50%;
					}
					> text {
						font-weight: 400;
						font-size: 22rpx;
						color: #c1c1c1;
						margin-left: 4rpx;
					}
				}
			}
		}
		> view:nth-child(2) {
			width: 100%;
			height: 210rpx;
			margin-bottom: 34rpx;
		}
		.setion {
			width: 100%;
			margin-bottom: 24rpx;
			padding: 42rpx 50rpx 30rpx 34rpx;
			box-sizing: border-box;
			box-shadow: 0 4rpx 8rpx rgba(0, 0, 0, 0.1);
			border-radius: 20rpx;
			> view:nth-child(1) {
				width: 100%;
				display: flex;
				align-items: center;
				image {
					width: 33rpx;
					height: 34rpx;
				}
				text {
					font-weight: bold;
					font-size: 28rpx;
					color: #333333;
					margin-left: 4rpx;
				}
			}
			> view:nth-child(2) {
				width: 100%;
				margin-top: 32rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #666666;
				line-height: 40rpx;
			}
			> view:nth-child(3) {
				width: 100%;
				margin-top: 24rpx;
				font-weight: 400;
				font-size: 24rpx;
				color: #666666;
				line-height: 40rpx;
			}
		}
		> view:nth-child(3) {
			background: linear-gradient(169deg, #d9ecff 0%, #ffffff 25%);
		}
		> view:nth-child(4) {
			background: linear-gradient(169deg, #fff9ef 0%, #ffffff 25%);
		}
		> view:nth-child(5) {
			background: linear-gradient(159deg, #e5fefb 0%, #ffffff 25%);
		}
		.pos {
			width: 100%;
			height: 166rpx;
		}
	}
	.bot-wrap {
		width: 100%;
		height: 166rpx;
		background: rgba(255, 255, 255, 1);
		position: fixed;
		bottom: 0;
		padding: 24rpx 30rpx 58rpx 32rpx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		.strat {
			width: 100%;
			height: 84rpx;
			text-align: center;
			line-height: 84rpx;
			font-weight: bold;
			font-size: 28rpx;
			color: #ffffff;
			background: #76a26f;
			border-radius: 42rpx;
		}
		.read {
			width: 40% !important;
			color: #000 !important;
			background: #ebebeb !important;
		}
		.again {
			width: 55% !important;
		}
	}
}
</style>
